package com.atguigu.guli.service.edu.feign;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.feign.fallback.OssFileServiceFallBack;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//service-oss 代表要访问服务的ip+端口号: http://localhost:8120
@Service
@FeignClient(value = "service-oss",fallback = OssFileServiceFallBack.class)//edu服务通过当前客户端访问哪个远程服务
public interface OssFileFeignClient {

    /*
    * 远程访问时,形参必须通过@RequestParam 或者@RequestBody 绑定
    * */
    //    处理文件删除
    @ApiOperation("文件删除")
    @DeleteMapping("/admin/oss/file/delete")
    public R deleteFile(
            @ApiParam(value = "模块名称", required = true)
            @RequestParam("module") String module,
            @RequestParam String path);


    //    处理文件批量删除
    @ApiOperation("文件批量删除")
    @DeleteMapping("/admin/oss/file/batchDelete")
    public R batchDeleteFile(
            @ApiParam(value = "模块名称", required = true)
            @RequestParam("module") String module,
            @RequestBody List<String> paths);




    @GetMapping("/admin/oss/test1")
    public R test1();

    @DeleteMapping("/admin/oss/test2")
    public R test2(@RequestParam String name);

    @PostMapping("/admin/oss/test3")
    public R test3(@RequestBody Teacher teacher);
}
